﻿using System.Web.Mvc;
using System.Web.Mvc.Html;
using System.Web.Routing;
using cludg.Domain.Users;

namespace cludg.Web.RenderHelpers
{
	public static class UserLinkRenderHelper
	{
		public static string ProfileUrl(this HtmlHelper html, string id)
		{
			return UrlHelper.GenerateUrl(
					null,
					"Profile",
					"Account",
					null,
					html.ViewContext.RequestContext.HttpContext.Request.Url.Host,
					null,
					new RouteValueDictionary(new { Id = id }),
					html.RouteCollection,
					html.ViewContext.RequestContext,
					true);
		}

		public static string ProfileUrl(this HtmlHelper html, User user)
		{
			return UrlHelper.GenerateUrl(
					"Profile",
					null,
					null,
					null,
					html.ViewContext.RequestContext.HttpContext.Request.Url.Host,
					null,
					new RouteValueDictionary(new { name = user.UniqueName }),
					html.RouteCollection,
					html.ViewContext.RequestContext,
					true);
		}

		public static MvcHtmlString ProfileLink(this HtmlHelper html, User user)
		{
			return html.RouteLink(user.DisplayName, "Profile", new { name = user.UniqueName }, null);
		}
	}
}
